const categoryStore = {
    state: {
        addCartData: {},
        recGoodsList:[]
    },
    mutations: {
        upDateCartData(state, payload) {
            state.addCartData = payload
        },

        // 更改某一商品选中状态
        upDateChecked(state, payload) {
            state.addCartData.isChecked = payload
        },
        //  更改全选状态
        upDateAllChecked(state, payload) {
            state.addCartData.isChecked = payload
        },

        // 删除指定Id的商品
        muDelGood(state) {
            state.addCartData={}
        }
    },
    actions: {
        commitCartData({ commit }, payload) {
            commit('upDateCartData', payload)
        },
        // 更改某一商品选中状态
        commitGoodsChecked({ commit }, payload) {
            commit('upDateChecked', payload)
        },
        //  更改全选状态
        commitGoodsAllChecked({ commit }, payload) {
            commit('upDateAllChecked', payload)
        },

        // 删除指定Id的商品
        acDelGood({commit}) {
            commit('muDelGood')
        }
    },
    getters: {
        cartData(state) {
            return state.addCartData
        },
        isChecked(state) {
            return state.addCartData.isChecked
        },
        isAllChecked(state) {
            return state.addCartData.isChecked
        },
        goodsAmount(state) {
            return state.addCartData.cartAmount
        }
    }
}

export default categoryStore